<template>
	<view class="order-data-list">
		<view class="order-data-tit">{{title}}</view>
		<block v-if="orderList.length">
			<view class="order-data-item" v-for="(data,index) in orderList" :key="index">
				<view class="order-data-item-time">{{data.add_time}}</view>
				<view class="order-data-list-cell">
					<label>订单编号</label>
					<text>{{data.order_id}}</text>
				</view>
				<view class="order-data-list-cell">
					<label>购买用户</label>
					<text v-if="data.user">{{data.user.user_id}}</text>
				</view>
				<view class="order-data-list-cell">
					<label>订单运费</label>
					<text>{{data.express_money}}元</text>
				</view>
				<view class="order-data-list-cell blue">
					<label>订单收入</label>
					<text>{{data.price}}元</text>
				</view>
				<view class="order-data-list-cell">
					<label>订单利润</label>
					<text>{{data.moneny_b}}元</text>
				</view>
				<view class="order-data-list-cell blue">
					<label>订单类型</label>
					<text>{{data.type==1?'店铺订单':'进货订单'}}</text>
				</view>
				<view class="order-data-a" @click="goOrderInfo(data.order_id)">查看详情</view>
			</view>
			<no-more :text="'数据加载完毕'" v-if="orderList.length && noMore"></no-more>
		</block>
		<block v-else>
			<nothing :text="'没有数据哦！'" :btn="false"></nothing>
		</block>
	</view>
</template>

<script>
	import utils from '@/components/shoyu-date/utils.filter.js';
	export default {
		data() {
			return {
				title: '',
				noMore: false,
				page: 0,
				time: '',
				orderList: []
			}
		},
		onLoad(options) {
			if(options.time){
				this.time = options.time
			}
			this.init()
		},
		onShow(){
		},
		onReachBottom() {
			if(!this.noMore){
				this.page++
				this.init(this.page)
			}
		},
		methods: {
			init(page){
				switch (this.time){
					case 'today':
						this.time = 'today'
						this.title = '今日业绩'
						break;
					case 'yesterday':
						this.time = 'yesterday'
						this.title = '昨日业绩'
						break;
					case 'month':
						this.time = 'month'
						this.title = '本月业绩'
						break;
					case 'lastMonth':
						this.time = 'lastMonth'
						this.title = '上月业绩'
						break;
					case 'year':
						this.time = 'year'
						this.title = '本年业绩'
						break;
					case 'lastYear':
						this.time = 'lastYear'
						this.title = '上年业绩'
						break;
				}
				let data = {}
				if(this.time){
					data = {
						page: page?page:0,
						time: this.time,
						store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id
					}
				}else{
					data = {
						page: page?page:0,
						store_id: JSON.parse(uni.getStorageSync('userInfo')).store_id
					}
				}
				this.$api.AdmindataMoneyList(data).then(res => {
					if(res.datas.list){
						res.datas.list.forEach(item => {
							this.orderList.push(item)
						})
					}else{
						this.noMore = true
					}
				})
			},
			goOrderInfo(id){
				uni.navigateTo({
					url: '/pages/data/order-data-info?id='+id
				})
			}
		}
	}
</script>

<style lang="scss">
	.order-data-list{
		.order-data-tit{
			padding: 20rpx 20rpx 0;
			font-size: 36rpx;
			font-weight: bold;
		}
		.order-data-item{
			.order-data-item-time{
				height: 80rpx;
				line-height: 80rpx;
				padding: 0 20rpx;
				color: #999;
				font-size: 28rpx;
			}
			.order-data-list-cell{
				background-color: #FFF;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 20rpx;
				margin-bottom: -10rpx;
				font-size: 28rpx;
				color: #666;
				&.blue{
					color: #2073F5;
				}
			}
			.order-data-a{
				text-align: center;
				font-size: 24rpx;
				color: #2073F5;
				font-weight: bold;
				background-color: #FFF;
				padding: 30rpx 0 50rpx;
				&::after{
					content: '';
					display: inline-block;
					vertical-align: middle;
					width: 16rpx;
					height: 16rpx;
					border-right: 4rpx solid #2073F5;
					border-top: 4rpx solid #2073F5;
					transform: rotate(45deg);
					margin-top: -4rpx;
				}
			}
		}
	}
</style>
